home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / gridex / frmgroup.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-01-02  |  10.6 KB  |  340 lines

  1. VERSION 5.00
  2. Begin VB.Form frmGroupBy 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Group By"
  5.    ClientHeight    =   5145
  6.    ClientLeft      =   2070
  7.    ClientTop       =   2475
  8.    ClientWidth     =   6015
  9.    Icon            =   "frmGroupBy.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   343
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   401
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin VB.ComboBox cboExpand 
  19.       Height          =   315
  20.       ItemData        =   "frmGroupBy.frx":014A
  21.       Left            =   2130
  22.       List            =   "frmGroupBy.frx":0155
  23.       Style           =   2  'Dropdown List
  24.       TabIndex        =   19
  25.       Top             =   4665
  26.       Width           =   2625
  27.    End
  28.    Begin VB.CommandButton cmdClearAll 
  29.       Caption         =   "Clear All"
  30.       Height          =   330
  31.       Left            =   4740
  32.       TabIndex        =   18
  33.       Top             =   1020
  34.       Width           =   1200
  35.    End
  36.    Begin VB.CommandButton cmdCancel 
  37.       Cancel          =   -1  'True
  38.       Caption         =   "Cancel"
  39.       Height          =   330
  40.       Left            =   4740
  41.       TabIndex        =   17
  42.       Top             =   630
  43.       Width           =   1200
  44.    End
  45.    Begin VB.CommandButton cmdOK 
  46.       Caption         =   "OK"
  47.       Default         =   -1  'True
  48.       Height          =   330
  49.       Left            =   4740
  50.       TabIndex        =   16
  51.       Top             =   240
  52.       Width           =   1200
  53.    End
  54.    Begin VB.Frame Frame1 
  55.       Caption         =   "Then by"
  56.       Height          =   1005
  57.       Index           =   3
  58.       Left            =   480
  59.       TabIndex        =   12
  60.       Top             =   3555
  61.       Width           =   4290
  62.       Begin VB.OptionButton optOrder 
  63.          Caption         =   "Descending"
  64.          Enabled         =   0   'False
  65.          Height          =   255
  66.          Index           =   7
  67.          Left            =   2800
  68.          TabIndex        =   15
  69.          Top             =   555
  70.          Width           =   1320
  71.       End
  72.       Begin VB.OptionButton optOrder 
  73.          Caption         =   "Ascending"
  74.          Enabled         =   0   'False
  75.          Height          =   255
  76.          Index           =   6
  77.          Left            =   2800
  78.          TabIndex        =   14
  79.          Top             =   225
  80.          Value           =   -1  'True
  81.          Width           =   1320
  82.       End
  83.       Begin VB.ComboBox cboGroups 
  84.          Enabled         =   0   'False
  85.          Height          =   315
  86.          Index           =   3
  87.          Left            =   135
  88.          Style           =   2  'Dropdown List
  89.          TabIndex        =   13
  90.          Top             =   285
  91.          Width           =   2595
  92.       End
  93.    End
  94.    Begin VB.Frame Frame1 
  95.       Caption         =   "Then by"
  96.       Height          =   1005
  97.       Index           =   2
  98.       Left            =   360
  99.       TabIndex        =   8
  100.       Top             =   2420
  101.       Width           =   4290
  102.       Begin VB.OptionButton optOrder 
  103.          Caption         =   "Descending"
  104.          Enabled         =   0   'False
  105.          Height          =   255
  106.          Index           =   5
  107.          Left            =   2800
  108.          TabIndex        =   11
  109.          Top             =   555
  110.          Width           =   1320
  111.       End
  112.       Begin VB.OptionButton optOrder 
  113.          Caption         =   "Ascending"
  114.          Enabled         =   0   'False
  115.          Height          =   255
  116.          Index           =   4
  117.          Left            =   2820
  118.          TabIndex        =   10
  119.          Top             =   225
  120.          Value           =   -1  'True
  121.          Width           =   1320
  122.       End
  123.       Begin VB.ComboBox cboGroups 
  124.          Enabled         =   0   'False
  125.          Height          =   315
  126.          Index           =   2
  127.          Left            =   135
  128.          Style           =   2  'Dropdown List
  129.          TabIndex        =   9
  130.          Top             =   285
  131.          Width           =   2595
  132.       End
  133.    End
  134.    Begin VB.Frame Frame1 
  135.       Caption         =   "Then by"
  136.       Height          =   1005
  137.       Index           =   1
  138.       Left            =   240
  139.       TabIndex        =   4
  140.       Top             =   1285
  141.       Width           =   4290
  142.       Begin VB.ComboBox cboGroups 
  143.          Enabled         =   0   'False
  144.          Height          =   315
  145.          Index           =   1
  146.          Left            =   135
  147.          Style           =   2  'Dropdown List
  148.          TabIndex        =   7
  149.          Top             =   285
  150.          Width           =   2595
  151.       End
  152.       Begin VB.OptionButton optOrder 
  153.          Caption         =   "Ascending"
  154.          Enabled         =   0   'False
  155.          Height          =   255
  156.          Index           =   2
  157.          Left            =   2800
  158.          TabIndex        =   6
  159.          Top             =   225
  160.          Value           =   -1  'True
  161.          Width           =   1320
  162.       End
  163.       Begin VB.OptionButton optOrder 
  164.          Caption         =   "Descending"
  165.          Enabled         =   0   'False
  166.          Height          =   255
  167.          Index           =   3
  168.          Left            =   2790
  169.          TabIndex        =   5
  170.          Top             =   555
  171.          Width           =   1320
  172.       End
  173.    End
  174.    Begin VB.Frame Frame1 
  175.       Caption         =   "Group Items by"
  176.       Height          =   1005
  177.       Index           =   0
  178.       Left            =   120
  179.       TabIndex        =   0
  180.       Top             =   150
  181.       Width           =   4290
  182.       Begin VB.OptionButton optOrder 
  183.          Caption         =   "Descending"
  184.          Enabled         =   0   'False
  185.          Height          =   255
  186.          Index           =   1
  187.          Left            =   2800
  188.          TabIndex        =   3
  189.          Top             =   555
  190.          Width           =   1320
  191.       End
  192.       Begin VB.OptionButton optOrder 
  193.          Caption         =   "Ascending"
  194.          Enabled         =   0   'False
  195.          Height          =   255
  196.          Index           =   0
  197.          Left            =   2800
  198.          TabIndex        =   2
  199.          Top             =   225
  200.          Value           =   -1  'True
  201.          Width           =   1320
  202.       End
  203.       Begin VB.ComboBox cboGroups 
  204.          Height          =   315
  205.          Index           =   0
  206.          Left            =   135
  207.          Style           =   2  'Dropdown List
  208.          TabIndex        =   1
  209.          Top             =   285
  210.          Width           =   2595
  211.       End
  212.    End
  213.    Begin VB.Label Label1 
  214.       AutoSize        =   -1  'True
  215.       BackStyle       =   0  'Transparent
  216.       Caption         =   "Expand/Collapse:"
  217.       Height          =   195
  218.       Left            =   540
  219.       TabIndex        =   20
  220.       Top             =   4710
  221.       Width           =   1260
  222.    End
  223. Attribute VB_Name = "frmGroupBy"
  224. Attribute VB_GlobalNameSpace = False
  225. Attribute VB_Creatable = False
  226. Attribute VB_PredeclaredId = True
  227. Attribute VB_Exposed = False
  228. Option Explicit
  229. Dim m_OK As Boolean
  230. Private Sub cboGroups_Click(Index As Integer)
  231.     If cboGroups(Index).ListIndex = 0 Then
  232.         optOrder(Index * 2).Enabled = False
  233.         optOrder(Index * 2 + 1).Enabled = False
  234.         optOrder(Index * 2).Value = True
  235.         If Index < 3 Then
  236.             cboGroups(Index + 1).ListIndex = 0
  237.             cboGroups(Index + 1).Enabled = False
  238.         End If
  239.     Else
  240.         optOrder(Index * 2).Enabled = True
  241.         optOrder(Index * 2 + 1).Enabled = True
  242.         optOrder(Index * 2).Value = True
  243.         If Index < 3 Then
  244.             cboGroups(Index + 1).Enabled = True
  245.         End If
  246.     End If
  247. End Sub
  248. Public Sub GroupGrid(grid As GridEX)
  249. Dim cs As Columns
  250. Dim c As Column
  251. Dim i As Integer
  252. Dim j As Integer
  253. Dim gr As JSGridEX.Group
  254. Dim grs As JSGridEX.Groups
  255.     cboExpand.ListIndex = 0
  256.     For j = 0 To 3
  257.         cboGroups(j).AddItem "(None)"
  258.     Next
  259.     Set cs = grid.Columns
  260.     For i = 1 To cs.Count
  261.         Set c = cs.Item(i)
  262.         If c.ColumnType <> jgexIcon Then
  263.             For j = 0 To 3
  264.                 cboGroups(j).AddItem c.Tag
  265.                 cboGroups(j).ItemData(cboGroups(j).NewIndex) = c.Index
  266.             Next
  267.         End If
  268.     Next i
  269.     cboGroups(0).ListIndex = 0
  270.     For i = 1 To grid.Groups.Count
  271.         Set gr = grid.Groups.Item(i)
  272.         cboGroups(i - 1).Text = cs.Item(gr.ColIndex).Caption
  273.         If gr.SortOrder = 1 Then
  274.             optOrder((i - 1) * 2).Value = True
  275.         Else
  276.             optOrder((i - 1) * 2 + 1).Value = True
  277.         End If
  278.     Next i
  279.     m_OK = False
  280.     Show 1
  281.     Dim Changes As Boolean
  282.     Set grs = grid.Groups
  283.     If m_OK Then
  284.         For i = 0 To 3
  285.             If cboGroups(i).ListIndex = 0 Then
  286.                 If grs.Count > i Then
  287.                     Changes = True
  288.                     Exit For
  289.                 End If
  290.             Else
  291.                 If grs.Count >= i + 1 Then
  292.                     Set gr = grs.Item(i + 1)
  293.                     If gr.ColIndex <> cboGroups(i).ItemData(cboGroups(i).ListIndex) Then
  294.                         Changes = True
  295.                         Exit For
  296.                     Else
  297.                         If optOrder(i * 2).Value Then
  298.                             If gr.SortOrder <> 1 Then
  299.                                 Changes = True
  300.                                 Exit For
  301.                             End If
  302.                         Else
  303.                             If gr.SortOrder <> -1 Then
  304.                                 Changes = True
  305.                                 Exit For
  306.                             End If
  307.                         End If
  308.                     End If
  309.                 Else
  310.                     Changes = True
  311.                     Exit For
  312.                 End If
  313.             End If
  314.         Next
  315.     End If
  316.     If Changes Then
  317.         Screen.MousePointer = 11
  318.        ' grid.Parent.Refresh
  319.         grs.Clear
  320.         For i = 0 To 3
  321.             If cboGroups(i).ListIndex <> 0 Then
  322.                 grs.Add cboGroups(i).ItemData(cboGroups(i).ListIndex), IIf(optOrder(i * 2), 1, -1)
  323.             End If
  324.         Next
  325.         grid.RefreshGroups cboExpand.ItemData(cboExpand.ListIndex)
  326.         Screen.MousePointer = 0
  327.     End If
  328.     Unload Me
  329. End Sub
  330. Private Sub cmdCancel_Click()
  331.     Hide
  332. End Sub
  333. Private Sub cmdClearAll_Click()
  334.     cboGroups(0).ListIndex = 0
  335. End Sub
  336. Private Sub cmdOK_Click()
  337.     m_OK = True
  338.     Hide
  339. End Sub
  340.